<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of seth
 *
 * @author Fulvio
 */
class seth {
    
public static function regTaskStart($taskname, $arguments, $options){
        
    
        if (is_array($arguments))
            $arguments=implode (";", $arguments);
        
        if (is_array($options))
            $options=implode (";", $options);
        
        //Registra l'esecuzione del task nella tabella TaskLog
        $tasklog=Doctrine_Core::getTable('TaskLog')->findByNameAndArg($taskname,$arguments);
        
        if (!isset($tasklog)){
            $tasklog=new TaskLog();
        }
            
        $tasklog->setTaskname($taskname);
        $tasklog->setRunning(TRUE);
        
        $tasklog->setArguments($arguments);
        $tasklog->setOptions($options);
        
        $now=new DateTime();
        $tasklog->setStart($now->format('Y-m-d H:i:s'));
        $tasklog->setEnd(NULL);
        
        $tasklog->setOutput(getmypid());
        
        $tasklog->save();
        
        return $tasklog;
    }
public static function regTaskEnd($tasklog, $success){
    
        $tasklog->setRunning(false);
        $tasklog->setSuccess($success); 
        $now=new DateTime();
        $tasklog->setEnd($now->format('Y-m-d H:i:s'));
        $tasklog->save();
    }
    

}
?>
